﻿
Imports elpmis
Imports lpmsengi
Imports idsysctx

Public Class defaultlogin
    Inherits requestProcessor

    Public Const _pathidentity As String = network.pathSeperator + "deflogin"

    Public Overrides Function pathidentity() As String
        Return _pathidentity
    End Function

    Public Overrides Function process(ByVal context As httpContext) As Boolean
        Dim id As String = Nothing
        context.userInput(query.id, cookie.id, id)
        Dim usrk As String = Nothing
        context.userInput(query.userSiteRandomKey, cookie.userSiteRandomKey, usrk)
        Dim idctx As idcontext = Nothing
        idctx = New idcontext(getContextServer(context), id, usrk, context)
        If idctx.loggedIn() Then
            elpmis.context.insertThreadStaticVariable("id", typeDefination.string, id)
            elpmis.context.insertThreadStaticVariable("sitekey", typeDefination.string, usrk)
            elpmis.context.insertThreadStaticVariable("forceUpdateLoginUrl", _
                                                      typeDefination.string, _
                                                      idctx.forceUpdateLoginUrl())
            context.setforevercookie(cookie.id, id)
            context.setforevercookie(cookie.userSiteRandomKey, usrk)
            Return context.createControl(New nameLpmsControl("defaultlogin")).render()
        Else
            elpmis.context.insertThreadStaticVariable("loginUrl", typeDefination.string, idctx.loginUrl())
            Return context.createControl(New nameLpmsControl("trylogin")).render()
        End If
    End Function
End Class
